package com.mine.modules.vm.controller;


import com.mine.common.domain.vo.Result;
import com.mine.modules.vm.common.constant.BizConstant;
import com.mine.modules.vm.service.IVmAssetsService;
import com.mine.modules.vm.service.IVmMonitorService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import org.apache.commons.lang3.StringUtils;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author xujf
 * @since 2024-09-21
 */
@RestController
@RequestMapping("/vm/count")
@RequiredArgsConstructor
@Api(tags = "数据统计")
public class VmCountController {

    private final IVmAssetsService assetsService;

    private final IVmMonitorService vmMonitorService;

    @ApiOperation(value = "通过图层Id统计区域设备数量", notes = "通过图层Id统计区域设备数量")
    @RequestMapping(value = "/countOfRegionByLayerId", method = RequestMethod.GET)
    public Result<?> countOfRegionByLayerId(@RequestParam String layerId, @RequestParam String type) {
        if(StringUtils.equals(BizConstant.SCENE_ELEMENT_TYPE_MONITOR, type)){
            return vmMonitorService.countMonitorOfRegionByLayerId(layerId);
        }
        return assetsService.countAssetsOfRegionByLayerId(layerId);
    }

    @ApiOperation(value = "通过图层Id统计资产设备数量", notes = "通过图层Id统计资产设备数量")
    @RequestMapping(value = "/countAssetsByLayerId", method = RequestMethod.GET)
    public Result<?> countAssetsByLayerId(@RequestParam String layerId) {
        return assetsService.countAssetsByLayerId(layerId);
    }

    @ApiOperation(value = "通过图层Id统计监控设备数量", notes = "通过图层Id统计监控设备数量")
    @RequestMapping(value = "/countMonitorByLayerId", method = RequestMethod.GET)
    public Result<?> countMonitorByLayerId(@RequestParam String layerId) {
        return vmMonitorService.countMonitorByLayerId(layerId);
    }

}
